﻿namespace WMS6.Web.Outbound
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.BaseInfoServiceRef;
    using WMS6.Web.OutboundServiceRef;

    public class ShippingOrder : BasePage
    {
        protected HtmlInputButton btnAction;
        protected Button btnAddDetail;
        protected Button btnCopy;
        protected Button btnDelete;
        protected Button btnDeleteDetail;
        protected Button btnExplode;
        protected Button btnFinish;
        protected Button btnGoBack;
        protected Button btnImportData;
        protected Button btnNew;
        protected Button btnRefresh;
        protected Button btnSave;
        protected CheckBox chkBatchFlag;
        protected CheckBox chkEnablePacking;
        protected CheckBox chkShipTogether;
        protected DropDownList ddlContainerType;
        protected DropDownList ddlHandingType;
        protected DropDownList ddlIncoTerm;
        protected DropDownList ddlPaymentTerm;
        protected DropDownList ddlPriority;
        protected DropDownList ddlStatus;
        protected DropDownList ddlTransportionMode;
        protected DropDownList ddlType;
        protected DropDownList ddlWareHouseID;
        protected HtmlForm F7011;
        protected GridView gvOrderDetail;
        protected GridView gvPickDetail;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdnBatchFlag;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnCopy;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlInputHidden hdnFlag;
        protected HtmlInputHidden hdnFrom;
        protected HtmlInputHidden hdnLineID;
        protected HtmlInputHidden hdnOrderID;
        protected HtmlInputHidden hdnPageQty;
        protected HtmlInputHidden hdnPageType;
        protected HtmlInputHidden hdnTypeValue;
        protected HtmlInputButton htmlbtnReport;
        protected HtmlImage imgBillToID;
        protected HtmlImage imgConsigneeID;
        protected HtmlImage imgOwnerID;
        protected Label lblActualShipDate;
        protected Label lblB_Address;
        protected Label lblB_City;
        protected Label lblB_Company;
        protected Label lblB_Contact1;
        protected Label lblB_Contact2;
        protected Label lblB_Country;
        protected Label lblB_Email1;
        protected Label lblB_Email2;
        protected Label lblB_Fax1;
        protected Label lblB_Fax2;
        protected Label lblB_Phone1;
        protected Label lblB_Phone2;
        protected Label lblB_Prov;
        protected Label lblB_Zip;
        protected Label lblBillToID;
        protected Label lblC_Address;
        protected Label lblC_City;
        protected Label lblC_Contact1;
        protected Label lblC_Contact2;
        protected Label lblC_Country;
        protected Label lblC_Email1;
        protected Label lblC_Email2;
        protected Label lblC_Fax1;
        protected Label lblC_Fax2;
        protected Label lblC_Phone1;
        protected Label lblC_Phone2;
        protected Label lblC_Prov;
        protected Label lblC_Zip;
        protected Label lblCarrierID;
        protected Label lblCarrierName;
        protected Label lblCompany;
        protected Label lblConsigneeID;
        protected Label lblContainer_Qty;
        protected Label lblContainer_Type;
        protected Label lblDelivery_Place;
        protected Label lblDeliveryDate;
        protected Label lblDeparture_Date;
        protected Label lblDischarge_Place;
        protected Label lblDoor;
        protected Label lblDriver_Name;
        protected Label lblExternOrderID;
        protected Label lblExternOrderID2;
        protected Label lblHandling_Type;
        protected Label lblInco_Terms1;
        protected Label lblIntransitID;
        protected Label lblMsg;
        protected Label lblOrderDate;
        protected Label lblOrderGroup;
        protected Label lblOrderID;
        protected Label lblOrderID1;
        protected Label lblOrderID2;
        protected Label lblOrderID3;
        protected Label lblOrderID4;
        protected Label lblOwnerID;
        protected Label lblPacking_Location;
        protected Label lblPayment_Term;
        protected Label lblPriority;
        protected Label lblReferenceNum;
        protected Label lblRemark;
        protected Label lblRemark2;
        protected Label lblRequestShipDate;
        protected Label lblRoute;
        protected Label lblShippingOrder;
        protected Label lblSortation_Location;
        protected Label lblStage;
        protected Label lblStatus;
        protected Label lblStop;
        protected Label lblTotalAllcated;
        protected Label lblTotalAllcatedQty;
        protected Label lblTotalExtended;
        protected Label lblTotalExtendedPrice;
        protected Label lblTotalOriginal;
        protected Label lblTotalOriginalQty;
        protected Label lblTotalPicked;
        protected Label lblTotalPickedQty;
        protected Label lblTotalPreallocated;
        protected Label lblTotalPreallocatedQty;
        protected Label lblTotalQty;
        protected Label lblTotalShipped;
        protected Label lblTotalShippedQty;
        protected Label lblTotalUnit;
        protected Label lblTotalUnitPrice;
        protected Label lblTrailer_Number;
        protected Label lblTrailer_Owner;
        protected Label lblTransportion_Mode;
        protected Label lblTransportion_Service;
        protected Label lblTye;
        protected Label lblUdf1;
        protected Label lblUdf10;
        protected Label lblUdf2;
        protected Label lblUdf3;
        protected Label lblUdf4;
        protected Label lblUdf5;
        protected Label lblUdf6;
        protected Label lblUdf7;
        protected Label lblUdf8;
        protected Label lblUdf9;
        protected Label lblWareHouseID;
        protected LinkButton lnkbtnPrintOutbound;
        protected HtmlLink mycss;
        protected Label one1;
        protected Label one2;
        protected Label one3;
        protected Label one4;
        protected Label one5;
        protected Label one6;
        protected ScriptManager ScriptManager1;
        protected HtmlTableCell tdlnkbtnPrintOutbound;
        private decimal TotalAllcatedQty;
        private decimal TotalExtendedPrice;
        protected HtmlGenericControl totalOrderDetail;
        private decimal TotalOriginalQty;
        private decimal TotalPickedQty;
        private decimal TotalPreallocatedQty;
        private decimal TotalShippedQty;
        private decimal TotalUnitPrice;
        protected TextBox txtActualShipDate;
        protected TextBox txtB_Address;
        protected TextBox txtB_City;
        protected TextBox txtB_Company;
        protected TextBox txtB_Contact1;
        protected TextBox txtB_Contact2;
        protected TextBox txtB_Country;
        protected TextBox txtB_Email1;
        protected TextBox txtB_Email2;
        protected TextBox txtB_Fax1;
        protected TextBox txtB_Fax2;
        protected TextBox txtB_Phone1;
        protected TextBox txtB_Phone2;
        protected TextBox txtB_Prov;
        protected TextBox txtB_Zip;
        protected TextBox txtBillToID;
        protected TextBox txtC_Address;
        protected TextBox txtC_City;
        protected TextBox txtC_Company;
        protected TextBox txtC_Contact1;
        protected TextBox txtC_Contact2;
        protected TextBox txtC_Country;
        protected TextBox txtC_Email1;
        protected TextBox txtC_Email2;
        protected TextBox txtC_Fax1;
        protected TextBox txtC_Fax2;
        protected TextBox txtC_Phone1;
        protected TextBox txtC_Phone2;
        protected TextBox txtC_Prov;
        protected TextBox txtC_Zip;
        protected TextBox txtCarrierID;
        protected TextBox txtCarrierName;
        protected TextBox txtConsigneeID;
        protected TextBox txtContainer_Qty;
        protected TextBox txtDelivery_Place;
        protected TextBox txtDeliveryDate;
        protected TextBox txtDeparture_Date;
        protected TextBox txtDischarge_Place;
        protected TextBox txtDoor;
        protected TextBox txtDriver_Name;
        protected TextBox txtExternOrderID;
        protected TextBox txtExternOrderID2;
        protected TextBox txtIntransitID;
        protected TextBox txtOrder3;
        protected TextBox txtOrder4;
        protected TextBox txtOrderDate;
        protected TextBox txtOrderGroup;
        protected TextBox txtOrderID;
        protected TextBox txtOrderID1;
        protected TextBox txtOrderID2;
        protected TextBox txtOwnerID;
        protected TextBox txtPacking_Location;
        protected TextBox txtReferenceNum;
        protected TextBox txtRemark;
        protected TextBox txtRemark2;
        protected TextBox txtRequestShipDate;
        protected TextBox txtRoute;
        protected TextBox txtSortation_Location;
        protected TextBox txtStage;
        protected TextBox txtStop;
        protected TextBox txtTotalQty;
        protected TextBox txtTrailer_Number;
        protected TextBox txtTrailer_Owner;
        protected TextBox txtTransportion_Service;
        protected TextBox txtUdf1;
        protected TextBox txtUdf10;
        protected TextBox txtUdf2;
        protected TextBox txtUdf3;
        protected TextBox txtUdf4;
        protected TextBox txtUdf5;
        protected TextBox txtUdf6;
        protected TextBox txtUdf7;
        protected TextBox txtUdf8;
        protected TextBox txtUdf9;
        protected UpdatePanel up1;

        protected void btnAddDetail_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ddlStatus.SelectedValue.ToUpper() == "NEW")
                {
                    if (string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                    {
                        this.lblMsg.Text = base.GetGlobalMsgResource("F7100_016");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(this.hdnOrderID.Value))
                        {
                            if (string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                            {
                                this.lblMsg.Text = base.GetGlobalMsgResource("F7100_016");
                                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',1,6);</script>", false);
                                return;
                            }
                            if (string.IsNullOrEmpty(this.txtDeparture_Date.Text.Trim()))
                            {
                                this.lblMsg.Text = base.GetGlobalMsgResource("F7100_007");
                                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',4,6);</script>", false);
                                return;
                            }
                            this.InsertShippingOrderInfo();
                        }
                        base.Response.Redirect(string.Format("ShippingOrderDetail.aspx?from={0}&ID={1}&SeqNO={2}&OwnerID={3}", new object[] { base.UrlEncode(this.hdnFrom.Value), base.UrlEncode(this.txtOrderID.Text.Trim()), base.UrlEncode(this.hdnLineID.Value), base.UrlEncode(this.txtOwnerID.Text.Trim()) }), false);
                    }
                }
                else
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_017");
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
        }

        protected void btnCopy_Click(object sender, EventArgs e)
        {
            this.txtOrderID.Text = "";
            this.txtOrderID.Enabled = true;
            this.txtActualShipDate.Text = "";
            this.txtOrderID1.Enabled = true;
            this.txtOrderID1.Text = "";
            this.txtOrderID2.Enabled = true;
            this.txtOrderID2.Text = "";
            this.txtOrder3.Enabled = true;
            this.txtOrder3.Text = "";
            this.txtOrder4.Enabled = true;
            this.txtOrder4.Text = "";
            this.hdnOrderID.Value = "";
            this.ddlStatus.SelectedValue = "New";
            this.btnAddDetail.Visible = false;
            this.btnDeleteDetail.Visible = false;
            this.btnExplode.Visible = false;
            this.btnImportData.Visible = false;
            OrdersInfo orderInfo = (OrdersInfo) base.DataEntityViewState;
            if ((orderInfo.OrderDetailInfos != null) && (orderInfo.OrderDetailInfos.Count > 0))
            {
                foreach (OrderDetailInfo info in orderInfo.OrderDetailInfos)
                {
                    info.Status = "New";
                    info.PreallocatedQty = 0M;
                    info.AllocatedQty = 0M;
                    info.PickedQty = 0M;
                    info.ShippedQty = 0M;
                }
                base.DataEntityViewState = orderInfo;
                base.BindData2GridView(this.gvOrderDetail, orderInfo.OrderDetailInfos);
            }
            this.hdnFlag.Value = "0";
            this.hdnCopy.Value = "1";
            this.lblMsg.Text = base.GetGlobalMsgResource("F7100_020");
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtOrderID.Text.Trim()))
            {
                try
                {
                    if (this.ddlStatus.SelectedValue.ToUpper() != "NEW")
                    {
                        this.lblMsg.Text = base.GetGlobalMsgResource("F7100_013");
                    }
                    else
                    {
                        OrdersInfo ordersInfo = base.DataEntityViewState as OrdersInfo;
                        if (ordersInfo.BatchFlag == "Y")
                        {
                            this.lblMsg.Text = "该订单已被批量处理,无法删除！";
                        }
                        else
                        {
                            List<string> orderID = new List<string> {
                                this.txtOrderID.Text.Trim()
                            };
                            this.lblMsg.Text = OutboundServiceClientProxy.GetInstance().DeleteShippingOrderInfo(orderID) + base.GetGlobalMsgResource("F7100_014");
                            this.btnSave.Enabled = false;
                            this.btnDelete.Enabled = false;
                            this.btnCopy.Enabled = false;
                            base.DataEntityViewState = null;
                            this.gvOrderDetail.Columns[1].Visible = false;
                            this.gvOrderDetail.Enabled = false;
                            this.btnAddDetail.Enabled = false;
                            this.btnDeleteDetail.Enabled = false;
                            this.btnExplode.Enabled = false;
                            this.btnImportData.Enabled = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_015") + ex.Message;
                }
            }
        }

        protected void btnDeleteDetail_Click(object sender, EventArgs e)
        {
            try
            {
                List<string> orderIDs = base.GetSelectedIDsInGridView(this.gvOrderDetail, "ORDERID");
                List<string> lineIDs = base.GetSelectedIDsInGridView(this.gvOrderDetail, "LINEID");
                List<string> listStatus = base.GetSelectedIDsInGridView(this.gvOrderDetail, "STATUS");
                if ((listStatus != null) && (listStatus.Count > 0))
                {
                    for (int i = 0; i < listStatus.Count; i++)
                    {
                        if (listStatus[i].ToUpper() != "NEW")
                        {
                            this.lblMsg.Text = base.GetGlobalMsgResource("F7100_018");
                            return;
                        }
                    }
                }
                if ((orderIDs == null) || (orderIDs.Count == 0))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_019");
                }
                else
                {
                    this.lblMsg.Text = OutboundServiceClientProxy.GetInstance().DeleteShippingOrderDetailByOrderIDsAndLineIDs(orderIDs, lineIDs) + base.GetGlobalMsgResource("F7100_014");
                    this.SetShippingOrderInfo2From();
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F7100_015") + ex.Message;
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);</script>", false);
            }
        }

        protected void btnExplode_Click(object sender, EventArgs e)
        {
            List<string> orderIDs = base.GetSelectedIDsInGridView(this.gvOrderDetail, "ORDERID");
            List<string> lineIDs = base.GetSelectedIDsInGridView(this.gvOrderDetail, "LINEID");
            List<string> Status = base.GetSelectedIDsInGridView(this.gvOrderDetail, "STATUS");
            try
            {
                if ((orderIDs == null) || (orderIDs.Count == 0))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_019");
                }
                else
                {
                    string strMsg = string.Empty;
                    if ((Status != null) && (Status.Count > 0))
                    {
                        for (int i = 0; i < Status.Count; i++)
                        {
                            if (Status[i].ToUpper() != "NEW")
                            {
                                this.lblMsg.Text = base.GetGlobalMsgResource("F7100_021");
                                return;
                            }
                        }
                        strMsg = OutboundServiceClientProxy.GetInstance().ExecuteExploding(orderIDs, lineIDs);
                        if (string.IsNullOrEmpty(strMsg))
                        {
                            this.lblMsg.Text = base.GetGlobalMsgResource("F7100_022");
                        }
                        else
                        {
                            this.lblMsg.Text = string.Format(base.GetGlobalMsgResource("F7100_023"), strMsg);
                        }
                        this.SetShippingOrderInfo2From();
                    }
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F7100_024") + ex.Message;
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);</script>", false);
            }
        }

        protected void btnFinish_Click(object sender, EventArgs e)
        {
            string strValue = string.Empty;
            try
            {
                List<string> pickDetailIDs = base.GetSelectedIDsInGridView(this.gvPickDetail, "PickDetailID");
                List<string> status = base.GetSelectedIDsInGridView(this.gvPickDetail, "Status");
                if ((status != null) && (status.Count > 0))
                {
                    for (int i = 0; i < status.Count; i++)
                    {
                        if ((status[i].ToUpper() != "SHIPPED") && (status[i].ToUpper() != "PART-SHIPPED"))
                        {
                            this.lblMsg.Text = "只能导入已发货或部分发货状态的行项!";
                            return;
                        }
                        strValue = strValue + pickDetailIDs[i] + ",";
                    }
                }
                if ((pickDetailIDs == null) || (pickDetailIDs.Count == 0))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_019");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'> window.returnValue ='" + this.txtOrderID.Text + ";" + strValue + "';  window.close();</script>", false);
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F7100_015") + ex.Message;
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);</script>", false);
            }
        }

        protected void btnGoBack_Click(object sender, EventArgs e)
        {
            if (base.Request.QueryString["type"] == "4RETURN")
            {
                base.Response.Redirect(string.Format("ShippingOrderList.aspx?action={0}&type={1}", base.UrlEncode(this.hdnActionID.Value.Trim()), base.Request.QueryString["type"]), false);
            }
            else
            {
                switch (this.hdnFrom.Value)
                {
                    case "query":
                        base.Response.Redirect("ShippingOrderQuery.aspx", false);
                        break;

                    case "list":
                        base.Response.Redirect("ShippingOrderList.aspx?from=edit", false);
                        break;
                }
            }
        }

        protected void btnImportData_Click(object sender, EventArgs e)
        {
            if (this.ddlStatus.SelectedValue.ToUpper() == "NEW")
            {
                if (string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_016");
                    return;
                }
                if (string.IsNullOrEmpty(this.hdnLineID.Value))
                {
                    this.InsertShippingOrderInfo();
                    this.hdnLineID.Value = "10";
                }
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);DataImport();</script>", false);
            }
            ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);</script>", false);
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.txtOwnerID.Text.Trim()))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_002");
                    ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',1,6);</script>", false);
                }
                else if (string.IsNullOrEmpty(this.txtOrderDate.Text.Trim()))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_003");
                    ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',1,6);</script>", false);
                }
                else if (string.IsNullOrEmpty(this.txtRequestShipDate.Text.Trim()))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_004");
                    ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',1,6);</script>", false);
                }
                else if (string.IsNullOrEmpty(this.txtDeliveryDate.Text.Trim()))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_006");
                    ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',1,6);</script>", false);
                }
                else if (string.IsNullOrEmpty(this.txtDeparture_Date.Text.Trim()))
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_007");
                    ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',4,6);</script>", false);
                }
                else
                {
                    if (this.hdnFlag.Value == "1")
                    {
                        this.UpdateShippingOrderInfo();
                    }
                    else
                    {
                        this.InsertShippingOrderInfo();
                    }
                    this.ddlType.Enabled = false;
                    this.txtOwnerID.Enabled = false;
                    this.imgOwnerID.Visible = false;
                    this.ddlWareHouseID.Enabled = false;
                    this.txtIntransitID.Enabled = false;
                    this.txtOrderID.Enabled = false;
                    this.txtOrderID1.Enabled = false;
                    this.txtOrderID2.Enabled = false;
                    this.txtOrder3.Enabled = false;
                    this.txtOrder4.Enabled = false;
                    this.CountrolsClick();
                    this.hdnPageQty.Value = "0";
                }
            }
            catch (Exception ex)
            {
                base.ShowMsgLabel(this.lblMsg, ex.Message);
            }
        }

        private void CountrolsClick()
        {
            this.txtOrderID.Attributes.Add("RecordValue", "0");
            this.txtOrderID.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrderID.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOrderID1.Attributes.Add("RecordValue", "0");
            this.txtOrderID1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrderID1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOrderID2.Attributes.Add("RecordValue", "0");
            this.txtOrderID2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrderID2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOrder3.Attributes.Add("RecordValue", "0");
            this.txtOrder3.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrder3.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOrder4.Attributes.Add("RecordValue", "0");
            this.txtOrder4.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrder4.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlStatus.Attributes.Add("RecordValue", "0");
            this.ddlStatus.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlStatus.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlType.Attributes.Add("RecordValue", "0");
            this.ddlType.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlType.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlType.Attributes.Add("RecordValue", "0");
            this.ddlType.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlType.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOrderDate.Attributes.Add("RecordValue", "0");
            this.txtOrderDate.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrderDate.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOwnerID.Attributes.Add("RecordValue", "0");
            this.txtOwnerID.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOwnerID.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOrderGroup.Attributes.Add("RecordValue", "0");
            this.txtOrderGroup.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrderGroup.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtReferenceNum.Attributes.Add("RecordValue", "0");
            this.txtReferenceNum.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtReferenceNum.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOrderGroup.Attributes.Add("RecordValue", "0");
            this.txtOrderGroup.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrderGroup.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtRequestShipDate.Attributes.Add("RecordValue", "0");
            this.txtRequestShipDate.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtRequestShipDate.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtOrderGroup.Attributes.Add("RecordValue", "0");
            this.txtOrderGroup.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtOrderGroup.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlPriority.Attributes.Add("RecordValue", "0");
            this.ddlPriority.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlPriority.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            if (this.ddlWareHouseID.Items.Count > 0)
            {
                this.ddlWareHouseID.Attributes.Add("RecordValue", "0");
                this.ddlWareHouseID.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlWareHouseID.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            }
            this.txtIntransitID.Attributes.Add("RecordValue", "0");
            this.txtIntransitID.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtIntransitID.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtExternOrderID.Attributes.Add("RecordValue", "0");
            this.txtExternOrderID.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtExternOrderID.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtActualShipDate.Attributes.Add("RecordValue", "0");
            this.txtActualShipDate.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtActualShipDate.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtExternOrderID2.Attributes.Add("RecordValue", "0");
            this.txtExternOrderID2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtExternOrderID2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtDeliveryDate.Attributes.Add("RecordValue", "0");
            this.txtDeliveryDate.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtDeliveryDate.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtConsigneeID.Attributes.Add("RecordValue", "0");
            this.txtConsigneeID.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtConsigneeID.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Company.Attributes.Add("RecordValue", "0");
            this.txtC_Company.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Company.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_City.Attributes.Add("RecordValue", "0");
            this.txtC_City.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_City.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Prov.Attributes.Add("RecordValue", "0");
            this.txtC_Prov.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Prov.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Contact1.Attributes.Add("RecordValue", "0");
            this.txtC_Contact1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Contact1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Contact2.Attributes.Add("RecordValue", "0");
            this.txtC_Contact2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Contact2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Zip.Attributes.Add("RecordValue", "0");
            this.txtC_Zip.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Zip.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Country.Attributes.Add("RecordValue", "0");
            this.txtC_Country.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Country.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Phone1.Attributes.Add("RecordValue", "0");
            this.txtC_Phone1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Phone1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Phone2.Attributes.Add("RecordValue", "0");
            this.txtC_Phone2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Phone2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Address.Attributes.Add("RecordValue", "0");
            this.txtC_Address.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Address.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Fax1.Attributes.Add("RecordValue", "0");
            this.txtC_Fax1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Fax1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Fax2.Attributes.Add("RecordValue", "0");
            this.txtC_Fax2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Fax2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Email1.Attributes.Add("RecordValue", "0");
            this.txtC_Email1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Email1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtC_Email2.Attributes.Add("RecordValue", "0");
            this.txtC_Email2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtC_Email2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtBillToID.Attributes.Add("RecordValue", "0");
            this.txtBillToID.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtBillToID.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Company.Attributes.Add("RecordValue", "0");
            this.txtB_Company.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Company.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_City.Attributes.Add("RecordValue", "0");
            this.txtB_City.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_City.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Prov.Attributes.Add("RecordValue", "0");
            this.txtB_Prov.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Prov.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Contact1.Attributes.Add("RecordValue", "0");
            this.txtB_Contact1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Contact1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Contact2.Attributes.Add("RecordValue", "0");
            this.txtB_Contact2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Contact2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Zip.Attributes.Add("RecordValue", "0");
            this.txtB_Zip.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Zip.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Country.Attributes.Add("RecordValue", "0");
            this.txtB_Country.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Country.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Phone1.Attributes.Add("RecordValue", "0");
            this.txtB_Phone1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Phone1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Phone2.Attributes.Add("RecordValue", "0");
            this.txtB_Phone2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Phone2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Address.Attributes.Add("RecordValue", "0");
            this.txtB_Address.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Address.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Fax1.Attributes.Add("RecordValue", "0");
            this.txtB_Fax1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Fax1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Fax2.Attributes.Add("RecordValue", "0");
            this.txtB_Fax2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Fax2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Email1.Attributes.Add("RecordValue", "0");
            this.txtB_Email1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Email1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtB_Email2.Attributes.Add("RecordValue", "0");
            this.txtB_Email2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtB_Email2.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlIncoTerm.Attributes.Add("RecordValue", "0");
            this.ddlIncoTerm.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlIncoTerm.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtDoor.Attributes.Add("RecordValue", "0");
            this.txtDoor.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtDoor.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtTrailer_Number.Attributes.Add("RecordValue", "0");
            this.txtTrailer_Number.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtTrailer_Number.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtCarrierID.Attributes.Add("RecordValue", "0");
            this.txtCarrierID.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtCarrierID.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlPaymentTerm.Attributes.Add("RecordValue", "0");
            this.ddlPaymentTerm.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlPaymentTerm.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtRoute.Attributes.Add("RecordValue", "0");
            this.txtRoute.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtRoute.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtTrailer_Owner.Attributes.Add("RecordValue", "0");
            this.txtTrailer_Owner.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtTrailer_Owner.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtCarrierName.Attributes.Add("RecordValue", "0");
            this.txtCarrierName.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtCarrierName.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtStop.Attributes.Add("RecordValue", "0");
            this.txtStop.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtStop.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtDriver_Name.Attributes.Add("RecordValue", "0");
            this.txtDriver_Name.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtDriver_Name.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtDeparture_Date.Attributes.Add("RecordValue", "0");
            this.txtDeparture_Date.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtDeparture_Date.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtDelivery_Place.Attributes.Add("RecordValue", "0");
            this.txtDelivery_Place.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtDelivery_Place.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtStage.Attributes.Add("RecordValue", "0");
            this.txtStage.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtStage.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlContainerType.Attributes.Add("RecordValue", "0");
            this.ddlContainerType.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlContainerType.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlTransportionMode.Attributes.Add("RecordValue", "0");
            this.ddlTransportionMode.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlTransportionMode.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtTransportion_Service.Attributes.Add("RecordValue", "0");
            this.txtTransportion_Service.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtTransportion_Service.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtContainer_Qty.Attributes.Add("RecordValue", "0");
            this.txtContainer_Qty.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtContainer_Qty.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtSortation_Location.Attributes.Add("RecordValue", "0");
            this.txtSortation_Location.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtSortation_Location.Text + "',this, 'hdnPageQty'); return true; ");
            this.ddlHandingType.Attributes.Add("RecordValue", "0");
            this.ddlHandingType.Attributes.Add("onfocusout", "RecordPageValue('" + this.ddlHandingType.SelectedItem.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtPacking_Location.Attributes.Add("RecordValue", "0");
            this.txtPacking_Location.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtPacking_Location.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtRemark2.Attributes.Add("RecordValue", "0");
            this.txtRemark2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtRemark2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtRemark.Attributes.Add("RecordValue", "0");
            this.txtRemark.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtRemark.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf1.Attributes.Add("RecordValue", "0");
            this.txtUdf1.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf1.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf2.Attributes.Add("RecordValue", "0");
            this.txtUdf2.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf2.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf3.Attributes.Add("RecordValue", "0");
            this.txtUdf3.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf3.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf4.Attributes.Add("RecordValue", "0");
            this.txtUdf4.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf4.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf5.Attributes.Add("RecordValue", "0");
            this.txtUdf5.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf5.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf6.Attributes.Add("RecordValue", "0");
            this.txtUdf6.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf6.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf7.Attributes.Add("RecordValue", "0");
            this.txtUdf7.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf7.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf8.Attributes.Add("RecordValue", "0");
            this.txtUdf8.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf8.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf9.Attributes.Add("RecordValue", "0");
            this.txtUdf9.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf9.Text + "',this, 'hdnPageQty'); return true; ");
            this.txtUdf10.Attributes.Add("RecordValue", "0");
            this.txtUdf10.Attributes.Add("onfocusout", "RecordPageValue('" + this.txtUdf10.Text + "',this, 'hdnPageQty'); return true; ");
        }

        protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (((this.hdnTypeValue.Value.ToUpper() != "RETURN") && (this.ddlType.SelectedValue.ToUpper() == "RETURN")) || ((this.hdnTypeValue.Value.ToUpper() == "RETURN") && (this.ddlType.SelectedValue.ToUpper() != "RETURN")))
            {
                this.txtConsigneeID.Text = "";
                this.txtC_Company.Text = "";
                this.txtC_City.Text = "";
                this.txtC_Prov.Text = "";
                this.txtC_Contact1.Text = "";
                this.txtC_Contact2.Text = "";
                this.txtC_Zip.Text = "";
                this.txtC_Country.Text = "";
                this.txtC_Phone1.Text = "";
                this.txtC_Phone2.Text = "";
                this.txtC_Address.Text = "";
                this.txtC_Fax1.Text = "";
                this.txtC_Fax2.Text = "";
                this.txtC_Email1.Text = "";
                this.txtC_Email2.Text = "";
            }
            this.hdnTypeValue.Value = this.ddlType.SelectedValue;
            if (string.Compare(this.ddlType.SelectedValue, "Return", true) == 0)
            {
                if (base.UserInfo.Preference.Lang.ToLower() == "zh-cn")
                {
                    this.lblConsigneeID.Text = "供应商代码";
                    this.lblCompany.Text = "供应商名称";
                }
                else
                {
                    this.lblConsigneeID.Text = "Vendor ID";
                    this.lblCompany.Text = "Vendor Name";
                }
            }
            else if (base.UserInfo.Preference.Lang.ToLower() == "zh-cn")
            {
                this.lblConsigneeID.Text = "收货人代码";
                this.lblCompany.Text = "收货人名称";
            }
            else
            {
                this.lblConsigneeID.Text = "Consignee ID";
                this.lblCompany.Text = "Company";
            }
            string CS40001 = this.ddlType.SelectedValue.ToUpper();
            if ((CS40001 != null) && (CS40001 == "TRANSFER"))
            {
                this.ddlWareHouseID.Visible = true;
                this.lblWareHouseID.Visible = true;
                this.txtIntransitID.Visible = true;
                this.lblIntransitID.Visible = true;
                this.txtOrderID1.Enabled = false;
                this.txtConsigneeID.Enabled = false;
                this.txtC_Company.Enabled = false;
                this.txtC_City.Enabled = false;
                this.txtC_Prov.Enabled = false;
                this.txtC_Contact1.Enabled = false;
                this.txtC_Contact2.Enabled = false;
                this.txtC_Zip.Enabled = false;
                this.txtC_Country.Enabled = false;
                this.txtC_Phone1.Enabled = false;
                this.txtC_Phone2.Enabled = false;
                this.txtC_Address.Enabled = false;
                this.txtC_Fax1.Enabled = false;
                this.txtC_Fax2.Enabled = false;
                this.txtC_Email1.Enabled = false;
                this.txtC_Email2.Enabled = false;
                this.imgConsigneeID.Visible = false;
                this.txtOrderID2.Enabled = false;
                this.txtBillToID.Enabled = false;
                this.txtB_Company.Enabled = false;
                this.txtB_City.Enabled = false;
                this.txtB_Prov.Enabled = false;
                this.txtB_Contact1.Enabled = false;
                this.txtB_Contact2.Enabled = false;
                this.txtB_Zip.Enabled = false;
                this.txtB_Country.Enabled = false;
                this.txtB_Phone1.Enabled = false;
                this.txtB_Phone2.Enabled = false;
                this.txtB_Address.Enabled = false;
                this.txtB_Fax1.Enabled = false;
                this.txtB_Fax2.Enabled = false;
                this.txtB_Email1.Enabled = false;
                this.txtB_Email2.Enabled = false;
                this.imgBillToID.Visible = false;
            }
            else
            {
                this.ddlWareHouseID.Visible = false;
                this.lblWareHouseID.Visible = false;
                this.txtIntransitID.Visible = false;
                this.lblIntransitID.Visible = false;
                this.txtOrderID1.Enabled = true;
                this.txtConsigneeID.Enabled = true;
                this.txtC_Company.Enabled = true;
                this.txtC_City.Enabled = true;
                this.txtC_Prov.Enabled = true;
                this.txtC_Contact1.Enabled = true;
                this.txtC_Contact2.Enabled = true;
                this.txtC_Zip.Enabled = true;
                this.txtC_Country.Enabled = true;
                this.txtC_Phone1.Enabled = true;
                this.txtC_Phone2.Enabled = true;
                this.txtC_Address.Enabled = true;
                this.txtC_Fax1.Enabled = true;
                this.txtC_Fax2.Enabled = true;
                this.txtC_Email1.Enabled = true;
                this.txtC_Email2.Enabled = true;
                this.imgConsigneeID.Visible = true;
                this.txtOrderID2.Enabled = true;
                this.txtBillToID.Enabled = true;
                this.txtB_Company.Enabled = true;
                this.txtB_City.Enabled = true;
                this.txtB_Prov.Enabled = true;
                this.txtB_Contact1.Enabled = true;
                this.txtB_Contact2.Enabled = true;
                this.txtB_Zip.Enabled = true;
                this.txtB_Country.Enabled = true;
                this.txtB_Phone1.Enabled = true;
                this.txtB_Phone2.Enabled = true;
                this.txtB_Address.Enabled = true;
                this.txtB_Fax1.Enabled = true;
                this.txtB_Fax2.Enabled = true;
                this.txtB_Email1.Enabled = true;
                this.txtB_Email2.Enabled = true;
                this.imgBillToID.Visible = true;
            }
        }

        protected void gvOrderDetail_Init(object sender, EventArgs e)
        {
            base.InitDetailGridView("F7011", this.gvOrderDetail);
        }

        protected void gvOrderDetail_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            (sender as GridView).PageIndex = e.NewPageIndex;
            (sender as GridView).DataSource = (base.DataEntityViewState as OrdersInfo).OrderDetailInfos;
            (sender as GridView).DataBind();
            ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", " <script type=\"text/javascript\" >setTab('one',6,6) </script>", false);
        }

        protected void gvOrderDetail_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int i = this.gvOrderDetail.PageIndex * this.gvOrderDetail.PageSize;
                e.Row.Cells[2].Text = ((e.Row.RowIndex + 1) + i).ToString();
                base.SetGridViewLongTextLabel((Label) e.Row.FindControl("lblSkuDescr"));
                if (((Label) e.Row.FindControl("lblORIGINALQTY")) != null)
                {
                    this.TotalOriginalQty += decimal.Parse(((Label) e.Row.FindControl("lblORIGINALQTY")).Text);
                }
                if (((Label) e.Row.FindControl("lblPREALLOCATEDQTY")) != null)
                {
                    this.TotalPreallocatedQty += decimal.Parse(((Label) e.Row.FindControl("lblPREALLOCATEDQTY")).Text);
                }
                if (((Label) e.Row.FindControl("lblALLOCATEDQTY")) != null)
                {
                    this.TotalAllcatedQty += decimal.Parse(((Label) e.Row.FindControl("lblALLOCATEDQTY")).Text);
                }
                if (((Label) e.Row.FindControl("lblPICKEDQTY")) != null)
                {
                    this.TotalPickedQty += decimal.Parse(((Label) e.Row.FindControl("lblPICKEDQTY")).Text);
                }
                if (((Label) e.Row.FindControl("lblSHIPPEDQTY")) != null)
                {
                    this.TotalShippedQty += decimal.Parse(((Label) e.Row.FindControl("lblSHIPPEDQTY")).Text);
                }
                if (((Label) e.Row.FindControl("lblUnitPrice")) != null)
                {
                    this.TotalUnitPrice += decimal.Parse(((Label) e.Row.FindControl("lblUnitPrice")).Text);
                }
                if (((Label) e.Row.FindControl("lblExtendedPrice")) != null)
                {
                    this.TotalExtendedPrice += decimal.Parse(((Label) e.Row.FindControl("lblExtendedPrice")).Text);
                }
                if (e.Row.FindControl("lblSkuID") != null)
                {
                    ((Label) e.Row.FindControl("lblSkuID")).Attributes.Add("onclick", "showInv('" + base.FormatUrl("../Inventory/InvLotLocLpnQuery.aspx?from=list&OwnerID={0}&SkuID={1}&History={2}", this.txtOwnerID.Text.Trim(), ((Label) e.Row.FindControl("lblSkuID")).Text.Trim(), "Y") + "')");
                }
            }
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                this.lblTotalOriginalQty.Text = base.GetPreferenceDigit(this.TotalOriginalQty);
                this.lblTotalPreallocatedQty.Text = base.GetPreferenceDigit(this.TotalPreallocatedQty);
                this.lblTotalAllcatedQty.Text = base.GetPreferenceDigit(this.TotalAllcatedQty);
                this.lblTotalPickedQty.Text = base.GetPreferenceDigit(this.TotalPickedQty);
                this.lblTotalShippedQty.Text = base.GetPreferenceDigit(this.TotalShippedQty);
                this.lblTotalUnitPrice.Text = base.GetPreferenceDigit(this.TotalUnitPrice);
                this.lblTotalExtendedPrice.Text = base.GetPreferenceDigit(this.TotalExtendedPrice);
            }
        }

        protected void gvOrderDetail_Sorting(object sender, GridViewSortEventArgs e)
        {
            try
            {
                string sortDirection = string.Empty;
                if (base.GridViewSortDirection == SortDirection.Ascending)
                {
                    base.GridViewSortDirection = SortDirection.Descending;
                    sortDirection = "DESC";
                }
                else
                {
                    base.GridViewSortDirection = SortDirection.Ascending;
                    sortDirection = "ASC";
                }
                OrdersInfo ordersInfo = base.DataEntityViewState as OrdersInfo;
                DataView dv = CADataConverter.ToDataTable(ordersInfo.OrderDetailInfos).DefaultView;
                dv.Sort = e.SortExpression + " " + sortDirection;
                base.BindData2GridView(this.gvOrderDetail, dv);
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);</script>", false);
            }
        }

        protected void gvPickDetail_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            (sender as GridView).PageIndex = e.NewPageIndex;
            (sender as GridView).DataSource = (base.DataEntityViewState as OrdersInfo).PickDetailInfos;
            (sender as GridView).DataBind();
            ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", " <script type=\"text/javascript\" >setTab('one',6,6) </script>", false);
        }

        protected void gvPickDetail_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int i = this.gvPickDetail.PageIndex * this.gvPickDetail.PageSize;
                e.Row.Cells[0].Text = ((e.Row.RowIndex + 1) + i).ToString();
                base.SetGridViewLongTextLabel((Label) e.Row.FindControl("lblSkuDescr"));
            }
        }

        protected void gvPickDetail_Sorting(object sender, GridViewSortEventArgs e)
        {
            try
            {
                string sortDirection = string.Empty;
                if (base.GridViewSortDirection == SortDirection.Ascending)
                {
                    base.GridViewSortDirection = SortDirection.Descending;
                    sortDirection = "DESC";
                }
                else
                {
                    base.GridViewSortDirection = SortDirection.Ascending;
                    sortDirection = "ASC";
                }
                OrdersInfo ordersInfo = base.DataEntityViewState as OrdersInfo;
                DataView dv = CADataConverter.ToDataTable(ordersInfo.PickDetailInfos).DefaultView;
                dv.Sort = e.SortExpression + " " + sortDirection;
                base.BindData2GridView(this.gvPickDetail, dv);
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);</script>", false);
            }
        }

        private void InsertShippingOrderInfo()
        {
            try
            {
                OrdersInfo ordersInfo = new OrdersInfo();
                if (base.DataEntityViewState != null)
                {
                    OrdersInfo SrcordersInfo = base.DataEntityViewState as OrdersInfo;
                    if ((this.hdnCopy.Value == "1") && ((SrcordersInfo.OrderDetailInfos != null) && (SrcordersInfo.OrderDetailInfos.Count > 0)))
                    {
                        ordersInfo.OrderDetailInfos = SrcordersInfo.OrderDetailInfos;
                    }
                }
                ordersInfo = this.SetOrdersInfo(ordersInfo);
                ordersInfo.BatchFlag = "N";
                ordersInfo.CreatedBy = base.UserInfo.UserID;
                ordersInfo.UpdatedBy = base.UserInfo.UserID;
                string orderID = OutboundServiceClientProxy.GetInstance().InsertShippingOrderInfo(ordersInfo);
                this.txtOrderID.Text = orderID;
                this.txtOrderID1.Text = orderID;
                this.txtOrderID2.Text = orderID;
                this.txtOrder3.Text = orderID;
                this.txtOrder4.Text = orderID;
                this.txtOrderID.Enabled = false;
                this.txtOrderID1.Enabled = false;
                this.txtOrderID2.Enabled = false;
                this.txtOrder3.Enabled = false;
                this.txtOrder4.Enabled = false;
                this.hdnOrderID.Value = orderID;
                this.hdnLineID.Value = "10";
                this.lblMsg.Text = orderID + base.GetGlobalMsgResource("F7100_011");
                this.hdnFlag.Value = "1";
                base.DataEntityViewState = ordersInfo;
                if (this.hdnCopy.Value == "1")
                {
                    this.SetShippingOrderInfo2From();
                    this.btnAddDetail.Visible = true;
                    this.btnDeleteDetail.Visible = true;
                    this.btnExplode.Visible = true;
                    this.btnImportData.Visible = true;
                }
                if ((ordersInfo.OrderDetailInfos != null) && (ordersInfo.OrderDetailInfos.Count > 0))
                {
                    this.hdnLineID.Value = (ordersInfo.OrderDetailInfos[ordersInfo.OrderDetailInfos.Count - 1].LineID + 10).ToString();
                }
                else
                {
                    this.hdnLineID.Value = "10";
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F7100_012") + ex.Message;
            }
        }

        private void LoadData()
        {
            this.txtOrderDate.Text = base.GetPreferenceShortDate(DateTime.Now);
            this.txtRequestShipDate.Text = base.GetPreferenceShortDate(DateTime.Now);
            this.txtDeliveryDate.Text = base.GetPreferenceShortDate(DateTime.Now);
            this.txtDeparture_Date.Text = base.GetPreferenceShortDate(DateTime.Now);
            base.BindData2DDL4WareHouse(this.ddlWareHouseID);
            base.BindData2DDLBySysCode(this.ddlType, "OrderType");
            base.BindData2DDLBySysCode(this.ddlStatus, "OrderStatus");
            base.BindData2DDLBySysCode(this.ddlPriority, "OrderPriority");
            if ((this.ddlPriority.Items != null) && (this.ddlPriority.Items.Count > 0))
            {
                this.ddlPriority.SelectedValue = "3";
            }
            base.BindData2DDLBySysCode(this.ddlHandingType, "OrderHandlingType");
            base.BindData2DDLBySysCode(this.ddlIncoTerm, "IncoTerms");
            base.BindData2DDLBySysCode(this.ddlPaymentTerm, "PaymentTerms");
            base.BindData2DDLBySysCode(this.ddlTransportionMode, "TransportMode");
            base.BindData2DDLBySysCode(this.ddlContainerType, "ContainerType");
            if (!string.IsNullOrEmpty(base.Request.QueryString["ID"]))
            {
                this.hdnOrderID.Value = base.Request.QueryString["ID"].ToString();
                this.SetShippingOrderInfo2From();
                this.hdnFlag.Value = "1";
            }
            else
            {
                base.SetDefaultOwner(this.txtOwnerID);
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["from"]))
            {
                this.hdnFrom.Value = base.Request.QueryString["from"].ToString();
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["detail"]))
            {
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);</script>", false);
            }
            if (base.Request.QueryString["type"] == "4RETURN")
            {
                this.hdnActionID.Value = base.Request.QueryString["action"];
                this.btnAction.Visible = false;
                this.btnNew.Visible = false;
                this.btnSave.Visible = false;
                this.btnDelete.Visible = false;
                this.btnCopy.Visible = false;
                this.btnRefresh.Visible = false;
                this.htmlbtnReport.Visible = false;
                this.btnAddDetail.Visible = false;
                this.btnDeleteDetail.Visible = false;
                this.btnExplode.Visible = false;
                this.btnImportData.Visible = false;
                this.btnFinish.Visible = true;
                this.gvOrderDetail.Columns[1].Visible = false;
                this.hdnPageType.Value = "1";
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',6,6);</script>", false);
                this.gvOrderDetail.Visible = false;
                this.gvPickDetail.Visible = true;
                this.totalOrderDetail.Visible = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
                this.CountrolsClick();
            }
            this.lblMsg.Text = "";
        }

        private OrdersInfo SetOrdersInfo(OrdersInfo ordersInfo)
        {
            DateTime dt = DateTime.Now;
            decimal outDec = new decimal(0, 0, 0, false, 1);
            ordersInfo.OrderID = this.txtOrderID.Text.Trim();
            ordersInfo.Status = this.ddlStatus.SelectedValue;
            ordersInfo.Type = this.ddlType.SelectedValue;
            if (DateTime.TryParse(this.txtOrderDate.Text.Trim(), out dt))
            {
                ordersInfo.OrderDate = DateTime.Parse(this.txtOrderDate.Text.Trim());
            }
            else
            {
                ordersInfo.OrderDate = dt;
            }
            ordersInfo.OwnerID = this.txtOwnerID.Text;
            ordersInfo.OrderGroup = this.txtOrderGroup.Text;
            ordersInfo.ReferenceNum = this.txtReferenceNum.Text.Trim();
            if (DateTime.TryParse(this.txtRequestShipDate.Text.Trim(), out dt))
            {
                ordersInfo.RequestedShipDate = DateTime.Parse(this.txtRequestShipDate.Text.Trim());
            }
            else
            {
                ordersInfo.RequestedShipDate = dt;
            }
            ordersInfo.Priority = this.ddlPriority.SelectedValue;
            ordersInfo.ExternOrderID = this.txtExternOrderID.Text.Trim();
            ordersInfo.ExternalOrderId2 = this.txtExternOrderID2.Text;
            if (DateTime.TryParse(this.txtDeliveryDate.Text.Trim(), out dt))
            {
                ordersInfo.DeliveryDate = DateTime.Parse(this.txtDeliveryDate.Text.Trim());
            }
            else
            {
                ordersInfo.DeliveryDate = dt;
            }
            if (this.ddlWareHouseID.Items.Count > 0)
            {
                ordersInfo.DestWhDbID = this.ddlWareHouseID.SelectedValue;
            }
            ordersInfo.ConsigneeID = this.txtConsigneeID.Text;
            ordersInfo.CCompany = this.txtC_Company.Text;
            ordersInfo.CCity = this.txtC_City.Text;
            ordersInfo.CProv = this.txtC_Prov.Text;
            ordersInfo.CContact1 = this.txtC_Contact1.Text;
            ordersInfo.CContact2 = this.txtC_Contact2.Text;
            ordersInfo.CZip = this.txtC_Zip.Text;
            ordersInfo.CCountryCode = this.txtC_Country.Text;
            ordersInfo.CPhone1 = this.txtC_Phone1.Text;
            ordersInfo.CPhone2 = this.txtC_Phone2.Text;
            ordersInfo.CAddress = this.txtC_Address.Text;
            ordersInfo.CFax1 = this.txtC_Fax1.Text;
            ordersInfo.CFax2 = this.txtC_Fax2.Text;
            ordersInfo.CEmail1 = this.txtC_Email1.Text;
            ordersInfo.CEmail2 = this.txtC_Email2.Text;
            ordersInfo.BillToID = this.txtBillToID.Text;
            ordersInfo.BCompany = this.txtB_Company.Text;
            ordersInfo.BCity = this.txtB_City.Text;
            ordersInfo.BState = this.txtB_Prov.Text;
            ordersInfo.BContact1 = this.txtB_Contact1.Text;
            ordersInfo.BContact2 = this.txtB_Contact2.Text;
            ordersInfo.BZip = this.txtB_Zip.Text;
            ordersInfo.BCountryCode = this.txtB_Country.Text;
            ordersInfo.BPhone1 = this.txtB_Phone1.Text;
            ordersInfo.BPhone2 = this.txtB_Phone2.Text;
            ordersInfo.BAddress = this.txtB_Address.Text;
            ordersInfo.BFax1 = this.txtB_Fax1.Text;
            ordersInfo.BFax2 = this.txtB_Fax2.Text;
            ordersInfo.BEmail1 = this.txtB_Email1.Text;
            ordersInfo.BEmail2 = this.txtB_Email2.Text;
            ordersInfo.IncoTerms = this.ddlIncoTerm.SelectedValue;
            ordersInfo.Door = this.txtDoor.Text;
            ordersInfo.TrailerNumber = this.txtTrailer_Number.Text;
            ordersInfo.CarrierID = this.txtCarrierID.Text;
            ordersInfo.PaymentTerm = this.ddlPaymentTerm.SelectedValue;
            ordersInfo.Route = this.txtRoute.Text;
            ordersInfo.TrailerOwner = this.txtTrailer_Owner.Text;
            ordersInfo.CarrierName = this.txtCarrierName.Text;
            ordersInfo.DischargePlace = this.txtDischarge_Place.Text;
            ordersInfo.Stop = this.txtStop.Text;
            ordersInfo.DriverName = this.txtDriver_Name.Text;
            if (DateTime.TryParse(this.txtDeparture_Date.Text.Trim(), out dt))
            {
                ordersInfo.DepartureDate = DateTime.Parse(this.txtDeparture_Date.Text.Trim());
            }
            else
            {
                ordersInfo.DepartureDate = dt;
            }
            ordersInfo.DeliveryPlace = this.txtDelivery_Place.Text;
            ordersInfo.Stage = this.txtStage.Text;
            ordersInfo.ContainerType = this.ddlContainerType.SelectedValue;
            ordersInfo.TransportationMode = this.ddlTransportionMode.SelectedValue;
            ordersInfo.TransportationService = this.txtTransportion_Service.Text;
            if (decimal.TryParse(this.txtContainer_Qty.Text.Trim(), out outDec))
            {
                ordersInfo.ContainerQty = decimal.Parse(this.txtContainer_Qty.Text.Trim());
            }
            else
            {
                ordersInfo.ContainerQty = outDec;
            }
            ordersInfo.SortationLocation = this.txtSortation_Location.Text;
            ordersInfo.HandlingType = this.ddlHandingType.SelectedValue;
            ordersInfo.PackingLocation = this.txtPacking_Location.Text;
            ordersInfo.ShipTogether = this.chkShipTogether.Checked ? "Y" : "N";
            ordersInfo.EnablePacking = this.chkEnablePacking.Checked ? "Y" : "N";
            ordersInfo.Remark2 = this.txtRemark2.Text;
            ordersInfo.Remark = this.txtRemark.Text;
            ordersInfo.Udf1 = this.txtUdf1.Text;
            ordersInfo.Udf2 = this.txtUdf2.Text;
            ordersInfo.Udf3 = this.txtUdf3.Text;
            ordersInfo.Udf4 = this.txtUdf4.Text;
            ordersInfo.Udf5 = this.txtUdf5.Text;
            ordersInfo.Udf6 = this.txtUdf6.Text;
            ordersInfo.Udf7 = this.txtUdf7.Text;
            ordersInfo.Udf8 = this.txtUdf8.Text;
            ordersInfo.Udf9 = this.txtUdf9.Text;
            ordersInfo.Udf10 = this.txtUdf10.Text;
            ordersInfo.UpdateSource = "";
            ordersInfo.IsActive = "Y";
            return ordersInfo;
        }

        private void SetShippingOrderInfo2From()
        {
            string OrderID = this.hdnOrderID.Value.ToString();
            OrdersInfo orderInfo = OutboundServiceClientProxy.GetInstance().GetOrdersInfoByOrderID(OrderID);
            this.hdnBatchFlag.Value = orderInfo.BatchFlag;
            if (orderInfo.BatchFlag == "Y")
            {
                this.btnAddDetail.Enabled = false;
                this.btnDeleteDetail.Enabled = false;
                this.btnExplode.Enabled = false;
                this.btnImportData.Enabled = false;
            }
            base.DataEntityViewState = orderInfo;
            if (orderInfo != null)
            {
                this.SetShippingOrderInfo2From(orderInfo);
            }
        }

        private void SetShippingOrderInfo2From(OrdersInfo orderInfo)
        {
            this.txtOrderID.Text = orderInfo.OrderID;
            this.txtOrderID1.Text = orderInfo.OrderID;
            this.txtOrderID2.Text = orderInfo.OrderID;
            this.txtOrder3.Text = orderInfo.OrderID;
            this.txtOrder4.Text = orderInfo.OrderID;
            this.ddlStatus.SelectedValue = orderInfo.Status;
            this.ddlType.SelectedValue = orderInfo.Type;
            this.ddlType_SelectedIndexChanged(null, null);
            this.ddlType.Enabled = false;
            this.txtOrderDate.Text = base.GetPreferenceShortDate(orderInfo.OrderDate);
            this.txtOwnerID.Text = orderInfo.OwnerID;
            this.txtOwnerID.Enabled = false;
            this.imgOwnerID.Visible = false;
            this.txtOrderGroup.Text = orderInfo.OrderGroup;
            this.txtReferenceNum.Text = orderInfo.ReferenceNum;
            this.txtRequestShipDate.Text = base.GetPreferenceShortDate(orderInfo.RequestedShipDate);
            this.ddlPriority.SelectedValue = orderInfo.Priority;
            if (orderInfo.BatchFlag == "Y")
            {
                this.chkBatchFlag.Checked = true;
            }
            else
            {
                this.chkBatchFlag.Checked = false;
            }
            if (!string.IsNullOrEmpty(orderInfo.IntransitID) && (this.ddlWareHouseID.Items.Count > 0))
            {
                this.ddlWareHouseID.SelectedValue = orderInfo.DestWhDbID;
            }
            this.txtIntransitID.Text = orderInfo.IntransitID;
            this.ddlWareHouseID.Enabled = false;
            this.txtIntransitID.Enabled = false;
            this.txtExternOrderID.Text = orderInfo.ExternOrderID;
            this.txtActualShipDate.Text = base.GetPreferenceShortDate(orderInfo.ActualShipDate);
            this.txtExternOrderID2.Text = orderInfo.ExternalOrderId2;
            this.txtDeliveryDate.Text = base.GetPreferenceShortDate(orderInfo.DeliveryDate);
            this.txtConsigneeID.Text = orderInfo.ConsigneeID;
            this.txtC_Company.Text = orderInfo.CCompany;
            this.txtC_City.Text = orderInfo.CCity;
            this.txtC_Prov.Text = orderInfo.CProv;
            this.txtC_Contact1.Text = orderInfo.CContact1;
            this.txtC_Contact2.Text = orderInfo.CContact2;
            this.txtC_Zip.Text = orderInfo.CZip;
            this.txtC_Country.Text = orderInfo.CCountryCode;
            this.txtC_Phone1.Text = orderInfo.CPhone1;
            this.txtC_Phone2.Text = orderInfo.CPhone2;
            this.txtC_Address.Text = orderInfo.CAddress;
            this.txtC_Fax1.Text = orderInfo.CFax1;
            this.txtC_Fax2.Text = orderInfo.CFax2;
            this.txtC_Email1.Text = orderInfo.CEmail1;
            this.txtC_Email2.Text = orderInfo.CEmail2;
            this.txtBillToID.Text = orderInfo.BillToID;
            this.txtB_Company.Text = orderInfo.BCompany;
            this.txtB_City.Text = orderInfo.BCity;
            this.txtB_Prov.Text = orderInfo.BState;
            this.txtB_Contact1.Text = orderInfo.BContact1;
            this.txtB_Contact2.Text = orderInfo.BContact2;
            this.txtB_Zip.Text = orderInfo.BZip;
            this.txtB_Country.Text = orderInfo.BCountryCode;
            this.txtB_Phone1.Text = orderInfo.BPhone1;
            this.txtB_Phone2.Text = orderInfo.BPhone2;
            this.txtB_Address.Text = orderInfo.BAddress;
            this.txtB_Fax1.Text = orderInfo.BFax1;
            this.txtB_Fax2.Text = orderInfo.BFax2;
            this.txtB_Email1.Text = orderInfo.BEmail1;
            this.txtB_Email2.Text = orderInfo.BEmail2;
            if (orderInfo.IncoTerms != "")
            {
                this.ddlIncoTerm.SelectedValue = orderInfo.IncoTerms;
            }
            this.txtDoor.Text = orderInfo.Door;
            this.txtTrailer_Number.Text = orderInfo.TrailerNumber;
            this.txtCarrierID.Text = orderInfo.CarrierID;
            this.ddlPaymentTerm.SelectedValue = orderInfo.PaymentTerm;
            this.txtRoute.Text = orderInfo.Route;
            this.txtTrailer_Owner.Text = orderInfo.TrailerOwner;
            this.txtCarrierName.Text = orderInfo.CarrierName;
            this.txtDischarge_Place.Text = orderInfo.DischargePlace;
            this.txtStop.Text = orderInfo.Stop;
            this.txtDriver_Name.Text = orderInfo.DriverName;
            this.txtDeparture_Date.Text = base.GetPreferenceShortDate(orderInfo.DepartureDate);
            this.txtDelivery_Place.Text = orderInfo.DeliveryPlace;
            this.txtStage.Text = orderInfo.Stage;
            this.ddlContainerType.SelectedValue = orderInfo.ContainerType;
            this.ddlTransportionMode.SelectedValue = orderInfo.TransportationMode;
            this.txtTransportion_Service.Text = orderInfo.TransportationService;
            this.txtContainer_Qty.Text = base.GetPreferenceDigit(orderInfo.ContainerQty);
            this.txtSortation_Location.Text = orderInfo.SortationLocation;
            this.ddlHandingType.SelectedValue = orderInfo.HandlingType;
            this.txtPacking_Location.Text = orderInfo.PackingLocation;
            this.chkShipTogether.Checked = orderInfo.ShipTogether == "Y";
            this.chkEnablePacking.Checked = orderInfo.EnablePacking == "Y";
            this.txtRemark2.Text = orderInfo.Remark2;
            this.txtRemark.Text = orderInfo.Remark;
            this.txtUdf1.Text = orderInfo.Udf1;
            this.txtUdf2.Text = orderInfo.Udf2;
            this.txtUdf3.Text = orderInfo.Udf3;
            this.txtUdf4.Text = orderInfo.Udf4;
            this.txtUdf5.Text = orderInfo.Udf5;
            this.txtUdf6.Text = orderInfo.Udf6;
            this.txtUdf7.Text = orderInfo.Udf7;
            this.txtUdf8.Text = orderInfo.Udf8;
            this.txtUdf9.Text = orderInfo.Udf9;
            this.txtUdf10.Text = orderInfo.Udf10;
            if ((orderInfo.OrderDetailInfos != null) && (orderInfo.OrderDetailInfos.Count > 0))
            {
                this.hdnLineID.Value = (orderInfo.OrderDetailInfos[orderInfo.OrderDetailInfos.Count - 1].LineID + 10).ToString();
            }
            else
            {
                this.hdnLineID.Value = "10";
            }
            base.BindData2GridView(this.gvOrderDetail, orderInfo.OrderDetailInfos);
            base.BindData2GridView(this.gvPickDetail, orderInfo.PickDetailInfos);
            this.txtOrderID.Enabled = false;
            this.txtOrderID1.Enabled = false;
            this.txtOrderID2.Enabled = false;
            this.txtOrder3.Enabled = false;
            this.txtOrder4.Enabled = false;
        }

        protected void txtBillToID_TextChanged(object sender, EventArgs e)
        {
            BillingEntityInfo tradePartnerInfo = BaseInfoServiceClientProxy.GetInstance().GetInfoByID(this.txtBillToID.Text.Trim(), "BILLING_ENTITY") as BillingEntityInfo;
            if (!((tradePartnerInfo == null) || string.IsNullOrEmpty(tradePartnerInfo.BillingEntityID)))
            {
                this.txtB_Company.Text = tradePartnerInfo.Company;
                this.txtB_City.Text = tradePartnerInfo.City;
                this.txtB_Prov.Text = tradePartnerInfo.State;
                this.txtB_Zip.Text = tradePartnerInfo.Zip;
                this.txtB_Country.Text = tradePartnerInfo.Country;
                this.txtB_Address.Text = tradePartnerInfo.Address;
                this.txtB_Contact1.Text = tradePartnerInfo.Contact1;
                this.txtB_Phone1.Text = tradePartnerInfo.Phone1;
                this.txtB_Fax1.Text = tradePartnerInfo.Fax1;
                this.txtB_Email1.Text = tradePartnerInfo.Email1;
                this.txtB_Contact2.Text = tradePartnerInfo.Contact2;
                this.txtB_Phone2.Text = tradePartnerInfo.Phone2;
                this.txtB_Fax2.Text = tradePartnerInfo.Fax2;
                this.txtB_Email2.Text = tradePartnerInfo.Email2;
                ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',3,6);</script>", false);
            }
            this.txtBillToID.Focus();
            this.hdnPageType.Value = "0";
        }

        protected void txtConsigneeID_TextChanged(object sender, EventArgs e)
        {
            if (string.Compare(this.hdnTypeValue.Value, "Return", true) == 0)
            {
                VendorInfo tradePartnerInfo = BaseInfoServiceClientProxy.GetInstance().GetInfoByID(this.txtConsigneeID.Text.Trim(), "VENDOR") as VendorInfo;
                if (!((tradePartnerInfo == null) || string.IsNullOrEmpty(tradePartnerInfo.VendorID)))
                {
                    this.txtC_Company.Text = tradePartnerInfo.Company;
                    this.txtC_City.Text = tradePartnerInfo.City;
                    this.txtC_Prov.Text = tradePartnerInfo.State;
                    this.txtC_Zip.Text = tradePartnerInfo.Zip;
                    this.txtC_Country.Text = tradePartnerInfo.Country;
                    this.txtC_Address.Text = tradePartnerInfo.Address;
                    this.txtC_Contact1.Text = tradePartnerInfo.Contact1;
                    this.txtC_Phone1.Text = tradePartnerInfo.Phone1;
                    this.txtC_Fax1.Text = tradePartnerInfo.Fax1;
                    this.txtC_Email1.Text = tradePartnerInfo.Email1;
                    this.txtC_Contact2.Text = tradePartnerInfo.Contact2;
                    this.txtC_Phone2.Text = tradePartnerInfo.Phone2;
                    this.txtC_Fax2.Text = tradePartnerInfo.Fax2;
                    this.txtC_Email2.Text = tradePartnerInfo.Email2;
                }
            }
            else
            {
                CustomerInfo tradePartnerInfo = BaseInfoServiceClientProxy.GetInstance().GetInfoByID(this.txtConsigneeID.Text.Trim(), "CUSTOMER") as CustomerInfo;
                if (!((tradePartnerInfo == null) || string.IsNullOrEmpty(tradePartnerInfo.CustomerID)))
                {
                    this.txtC_Company.Text = tradePartnerInfo.Company;
                    this.txtC_City.Text = tradePartnerInfo.City;
                    this.txtC_Prov.Text = tradePartnerInfo.State;
                    this.txtC_Zip.Text = tradePartnerInfo.Zip;
                    this.txtC_Country.Text = tradePartnerInfo.Country;
                    this.txtC_Address.Text = tradePartnerInfo.Address;
                    this.txtC_Contact1.Text = tradePartnerInfo.Contact1;
                    this.txtC_Phone1.Text = tradePartnerInfo.Phone1;
                    this.txtC_Fax1.Text = tradePartnerInfo.Fax1;
                    this.txtC_Email1.Text = tradePartnerInfo.Email1;
                    this.txtC_Contact2.Text = tradePartnerInfo.Contact2;
                    this.txtC_Phone2.Text = tradePartnerInfo.Phone2;
                    this.txtC_Fax2.Text = tradePartnerInfo.Fax2;
                    this.txtC_Email2.Text = tradePartnerInfo.Email2;
                }
            }
            ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", "<script language='javascript'>setTab('one',2,6);</script>", false);
            this.txtConsigneeID.Focus();
            this.hdnPageType.Value = "0";
        }

        protected void txtOrderID_TextChanged(object sender, EventArgs e)
        {
            if (this.hdnCopy.Value != "1")
            {
                this.hdnOrderID.Value = this.txtOrderID.Text.Trim();
                this.SetShippingOrderInfo2From();
            }
        }

        private void UpdateShippingOrderInfo()
        {
            try
            {
                if (this.ddlStatus.SelectedValue.ToUpper() != "NEW")
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F7100_008");
                }
                else
                {
                    OrdersInfo ordersInfo = base.DataEntityViewState as OrdersInfo;
                    if (ordersInfo.BatchFlag == "Y")
                    {
                        this.lblMsg.Text = "该订单已被批量处理,无法修改！";
                    }
                    else
                    {
                        ordersInfo = this.SetOrdersInfo(ordersInfo);
                        ordersInfo.UpdatedBy = base.UserInfo.UserID;
                        this.lblMsg.Text = OutboundServiceClientProxy.GetInstance().UpdateShippingOrderInfo(ordersInfo) + base.GetGlobalMsgResource("F7100_009");
                    }
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F7100_010") + ex.Message;
            }
        }
    }
}

